
//By FreeSouth ieysx@163.com www.osgChina.org 2008 6 13 
#include <osgDB/ReadFile> 
#include <osgViewer/Viewer> 
#include <osg/Node> 
#include <osg/MatrixTransform> 


//void listAllAddress()
//{
//	QList<QHostAddress> list = QNetWorkInterface::allAddress();
//	for each (auto address in list)
//	{
//		if (address)
//		{
//			qDebug() << "Address: " << address.toString();
//		}
//	}
//}

int main(int argc, char *argv[])
{
	osgViewer::Viewer viewer; 
	osg::ref_ptr < osg::Group> root = new osg::Group(); 
	
	osg::ref_ptr < osg::Node> osgcool = osgDB::readNodeFile("osgcool.osgt"); 

	for (auto i = 0; i < 100; i += 10)
	{
		osg::ref_ptr < osg::MatrixTransform> trans = new osg::MatrixTransform;
		trans->setMatrix(osg::Matrix::translate(0, 0, i));
		trans->addChild(osgcool.get());
		root->addChild(trans.get());
	}

	for (auto i = 0; i > -100; i -= 10)
	{
		osg::ref_ptr < osg::MatrixTransform> scale3 = new osg::MatrixTransform;
		scale3->setMatrix(osg::Matrix::scale(0.5, 0.5, 0.5) * osg::Matrix::translate(-i, 0, i));
		scale3->addChild(osgcool.get());
		root->addChild(scale3.get());
	}

	for (auto i = 0; i > -100; i -= 10)
	{
		osg::ref_ptr < osg::MatrixTransform> scale3 = new osg::MatrixTransform;
		scale3->setMatrix(osg::Matrix::translate(i, 0, i) * osg::Matrix::scale(0.5, 0.5, 0.5));
		scale3->addChild(osgcool.get());
		root->addChild(scale3.get());
	}

	for (auto i = 0; i > -100; i -= 10)
	{
		osg::ref_ptr < osg::MatrixTransform > rot = new osg::MatrixTransform;
		rot->setMatrix(osg::Matrix::translate(10, 0, 10) * osg::Matrix::rotate(osg::DegreesToRadians(3.34 * i), 1, 0, 0)*osg::Matrix::scale(0.5, 0.5, 0.5));
		rot->addChild(osgcool.get());
		root->addChild(rot.get());
	}

	root->addChild(osgcool.get()); 

	viewer.setSceneData(root.get());
	viewer.realize(); 
	viewer.run();
}
